import java.util.Arrays;

public class testDemo {
    //数组的逆置
    public static void main1(String[] args) {
       int[] arr={1,2,3,4,5};
       reverse(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void reverse(int[] arr) {
        int i=0;
        int j=arr.length-1;
        while(i<j){
            int tmp=arr[i];
            arr[i]=arr[j];
            arr[j]=tmp;
            i++;
            j--;
        }
    }
    //偶数在前，奇数在后
    public static void func(int[] arr) {
        int i=0;
        int j=arr.length-1;
        while(i<j){
            while(i<j&&arr[i]%2==0){
                i++;
            }
            while(i<j&&arr[j]%2!=0){
                j--;
            }
            int tmp=arr[i];
            arr[i]=arr[j];
            arr[j]=tmp;
        }
    }
    public static void main(String[] args) {
        int[] arr={5,6,8,3,9,1};
        func(arr);
        System.out.println(Arrays.toString(arr));
    }
}


























